pallet-asset: Add new test case for InvalidAssetValue#520
pallet-asset: Add new test case for InvalidAssetValue#520rohansen856 wants to merge 7 commits intodhiway:develop_20250418from
Conversation
vatsa287
left a comment
There was a problem hiding this comment.
I see the requirement here that Invalid Asset Value may get triggered due either from asset_qty or asset_value.
Please check for both cases.
|
Use below for passing the rust format & add new commit. |
|
@rohansen856 While at it you can also check for |
|
@vatsa287 I have added test for the following cases: let negative_value_entry = AssetInputEntryOf::<Test> {
asset_desc: asset_desc.clone(),
asset_qty: 10, // Valid quantity
asset_type: asset_type.clone(),
asset_value: (0 - 1), // Invalid (negative) asset value
asset_tag: asset_tag.clone(),
asset_meta: asset_meta.clone(),
};let me know if any other changes or edge case inclusions are necessary. thank you. |
|
@rohansen856 Negative check is not required since it is handled at by the type itself. |
thanks for the follow up. i will remove the negative check and keep just the |
Goal
This pr solves the issue: #370 , adding new test cases for checking invalid asset values in
pallets/asset/src/tests.rs.#summary
Context:
creator, author, and capacity establish the initial conditions.
The test then generates unique identifiers for both the "space" and "authorization" using hashing functions to mimic blockchain data integrity practices.
Asset Entry with Invalid Value:
The entry variable represents an asset structure, with asset_value deliberately set to -10 to simulate an invalid value scenario.
This asset entry will be used to test the error handling in the Asset::create function.
Test Execution and Assertions:
Space::createandSpace::approveare called to prepare the environment, ensuring the space is created and approved before attempting asset creation.The core test assertion is
assert_err!, which confirms that callingAsset::createwith the invalid asset value returns the InvalidAssetValue error as expected.